import service from "@/api/index.js";
import qs from "qs";

const userApi = {
    //获取验证码
    captcha() {
      return service.get("/user/captcha")
    },
    //添加
    reg(user){
        return service.post("/user/reg",qs.stringify(user));
    },
    //登录
    login(user){
        return service.post("/user/login",qs.stringify(user));
    },
    //删除
    delete(id){
        return service.delete(`/user/${id}`);
    },
    //修改
    update(user){
        return service.put("/user",user);
    },
    //分页搜索
    selectByPage(condition, pageNum, pageSize){
        condition.pageNum = pageNum;
        condition.pageSize = pageSize;
        return service.get("/user",{
            params: condition
        });
    },
    //根据id搜索
    selectById(id){
        return service.get(`/user/${id}`);
    },
    getInfo() {
        return service.get("/user/info");
    },
    getUserLog() {
        return service.get("/user/log");
    },
    chgPwd(userByPassword){

        return service.put("/user/chgPwd", userByPassword)
    },
    chgPayPwd(userByPayPassword) {
        return service.put("/user/chgPayPwd", userByPayPassword)
    },
    userTop5(){
        return service.get("/user/userTop5")
    },
    recharge(user) {
        return service.put("/user/recharge", user)
    }
}

export default userApi;